package com.lvy.hczn.front.business.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lvy.hczn.front.system.domain.business.SpuGrade;
import com.lvy.hczn.front.business.mapper.SpuGradeMapper;
import com.lvy.hczn.front.business.service.SpuGradeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class SpuGradeServiceImpl extends ServiceImpl<SpuGradeMapper, SpuGrade> implements SpuGradeService {

    @Autowired
    private SpuGradeMapper spuGradeMapper;

    /**
     * 查询等级列表||spId||categoryId条件查询
     *
     * @param spuGrade
     * @return java.util.List<com.lvy.hczn.model.order.SpuGrade>
     * @author yw
     * @date 2022-07-27 16:28:32
     */
    @Override
    public List<SpuGrade> selectList(SpuGrade spuGrade) {
        LambdaQueryWrapper<SpuGrade> wrapper = new LambdaQueryWrapper();
        if (!StrUtil.isEmpty(spuGrade.getSpuId())) {
            wrapper.eq(SpuGrade::getSpuId, spuGrade.getSpuId());
        }
        if (!StrUtil.isEmpty(spuGrade.getCategoryId())) {
            wrapper.eq(SpuGrade::getCategoryId, spuGrade.getCategoryId());
        }
        return super.list(wrapper);
    }
}
